# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#                                                                              #
# TITLE      : Breaking Silence: How Intimate Partner Violence                #
#              And Reporting Shape Later Life Outcomes                        #
# AUTHOR     : Harrison Chang, Shiau-Fang Chao,                                #
#              Kuan-Ming Chen, Ming-Jen Lin                                    #
# CODE EDITOR: Harrison Chang                                                  #
# PURPOSE    : This .R generates all the figures in the paper                  #
#                                                                              #
#                                                                              #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

rm(list=ls());gc()

setwd("/Users/harrisonc/My Drive/Domestic_Violence/")

library(data.table)
library(tidyverse)
library(dplyr)
library(fixest) 
library(ggplot2)
library(RColorBrewer)


source("JOLE/publication/replication/code/function_replication.R")


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####                      Setting                    ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

right_bound     <- 4
left_bound      <- -5
xbks            <- seq(-5,4,1)
baseline        <- 0
subtitle        <- c()




# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####         Figure 1:  Reporting Distribution       ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

figure1         <- fread("JOLE/publication/replication/data/figure1.csv")
setnames(figure1, c("year","count","one","type"))

figure1[, total := sum(count), by = "type"][, percentage := count / total]

ggplot(figure1, aes(x = year, y = percentage, fill = type)) + 
  geom_bar(stat = "identity", position = position_dodge(width = 0.8), width = 0.6) + # Adjust bar width
  scale_x_discrete(limits = c(as.character(0:9), "10+")) + 
  labs(x = "Duration Year Between Violence and Report",
    y = "Share",
    fill = "Sample") + 
  theme_classic() + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
    plot.title = element_text(hjust = 0.5),
    legend.position = "bottom",
    legend.title = element_text(hjust = 0.5)) + 
  scale_fill_manual(values = c("A" = "red", "B" = "orange", "C" = "blue"),
    labels = c("A" = "Female Once-reporter",
      "B" = "Female Repeat-reporter",
      "C" = "Male Once-reporter"
    )
  )


ggsave("JOLE/publication/replication/figure/figure1.eps", device = "eps", width = 6, height = 4)




# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####              Figure 2: Employment Rate          ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

ylabel          <- c("Employment Rate")

#2A - violence effect
figure2A_vio    <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.045,0.04)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figure2A_vio)
ggsave("JOLE/publication/replication/figure/figure2/figure2A_violence.eps", device = "eps", width = 6, height = 4)

#2A - report effect
figure2A_rep    <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.045,0.04)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figure2A_rep)
ggsave("JOLE/publication/replication/figure/figure2/figure2A_report.eps", device = "eps", width = 6, height = 4)

#2B - violence effect
figure2B_vio    <- fread("JOLE/publication/replication/data/figure2/figure2B_violence.csv")
ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.045,0.04)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure2B_vio)
ggsave("JOLE/publication/replication/figure/figure2/figure2B_violence.eps", device = "eps", width = 6, height = 4)

#2B - report effect
figure2B_rep    <- fread("JOLE/publication/replication/data/figure2/figure2B_report.csv")
ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.045,0.04)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure2B_rep)
ggsave("JOLE/publication/replication/figure/figure2/figure2B_report.eps", device = "eps", width = 6, height = 4)

#2C - violence effect
figure2C_vio    <- fread("JOLE/publication/replication/data/figure2/figure2C_violence.csv")
ybks            <- round(seq(-0.1,0.075,0.025), digits = 3)
yscale          <- c(-0.1,0.075)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure2C_vio)
ggsave("JOLE/publication/replication/figure/figure2/figure2C_violence.eps", device = "eps", width = 6, height = 4)

#2C - report effect
figure2C_rep    <- fread("JOLE/publication/replication/data/figure2/figure2C_report.csv")
ybks            <- round(seq(-0.1,0.075,0.025), digits = 3)
yscale          <- c(-0.1,0.075)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure2C_rep)
ggsave("JOLE/publication/replication/figure/figure2/figure2C_report.eps", device = "eps", width = 6, height = 4)



# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####             Figure 3: Marital Decision         ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

ylabel          <- c("Get Divorced Dummy")

#3A - violence effect
figure3A_vio    <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
ybks            <- seq(0,0.1,0.02)
yscale          <- c(-0.01,0.105)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figure3A_vio)
ggsave("JOLE/publication/replication/figure/figure3/figure3A_violence.eps", device = "eps", width = 6, height = 4)

#3A - report effect
figure3A_rep    <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
ybks            <- seq(0,0.1,0.02)
yscale          <- c(-0.01,0.105)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figure3A_rep)
ggsave("JOLE/publication/replication/figure/figure3/figure3A_report.eps", device = "eps", width = 6, height = 4)

#3B - violence effect
figure3B_vio    <- fread("JOLE/publication/replication/data/figure3/figure3B_violence.csv")
ybks            <- seq(-0.02,0.12,0.02)
yscale          <- c(-0.02,0.125)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure3B_vio)
ggsave("JOLE/publication/replication/figure/figure3/figure3B_violence.eps", device = "eps", width = 6, height = 4)

#3B - report effect
figure3B_rep    <- fread("JOLE/publication/replication/data/figure3/figure3B_report.csv")
ybks            <- seq(-0.02,0.12,0.02)
yscale          <- c(-0.02,0.125)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure3B_rep)
ggsave("JOLE/publication/replication/figure/figure3/figure3B_report.eps", device = "eps", width = 6, height = 4)

#3C - violence effect
figure3C_vio    <- fread("JOLE/publication/replication/data/figure3/figure3C_violence.csv")
ybks            <- seq(-0.03,0.15,0.03)
yscale          <- c(-0.03,0.15)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure3C_vio)
ggsave("JOLE/publication/replication/figure/figure3/figure3C_violence.eps", device = "eps", width = 6, height = 4)

#3C - report effect
figure3C_rep    <- fread("JOLE/publication/replication/data/figure3/figure3C_report.csv")
ybks            <- seq(-0.03,0.15,0.03)
yscale          <- c(-0.03,0.15)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure3C_rep)
ggsave("JOLE/publication/replication/figure/figure3/figure3C_report.eps", device = "eps", width = 6, height = 4)


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####               Figure 4: Fertility Rate         ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#4A - violence effect
figure4A_vio    <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
ybks            <- round(seq(-0.1,0.1,0.05), digits = 3)
yscale          <- c(-0.11,0.1)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figure4A_vio)
ggsave("JOLE/publication/replication/figure/figure4/figure4A_violence.eps", device = "eps", width = 6, height = 4)

#4A - report effect
figure4A_rep    <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
ybks            <- round(seq(-0.1,0.1,0.05), digits = 3)
yscale          <- c(-0.11,0.1)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figure4A_rep)
ggsave("JOLE/publication/replication/figure/figure4/figure4A_report.eps", device = "eps", width = 6, height = 4)

#4B - violence effect
figure4B_vio     <- fread("JOLE/publication/replication/data/figure4/figure4B_violence.csv")
ybks            <- round(seq(-0.1,0.1,0.05), digits = 3)
yscale          <- c(-0.11,0.1)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure4B_vio)
ggsave("JOLE/publication/replication/figure/figure4/figure4B_violence.eps", device = "eps", width = 6, height = 4)

#4B - report effect
figure4B_rep    <- fread("JOLE/publication/replication/data/figure4/figure4B_report.csv")
ybks            <- round(seq(-0.1,0.1,0.05), digits = 3)
yscale          <- c(-0.11,0.1)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure4B_rep)
ggsave("JOLE/publication/replication/figure/figure4/figure4B_report.eps", device = "eps", width = 6, height = 4)

#4C - violence effect
figure4C_vio    <- fread("JOLE/publication/replication/data/figure4/figure4C_violence.csv")
ybks            <- round(seq(-0.2,0.1,0.05), digits=2)
yscale          <- c(-0.2,0.1)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure4C_vio)
ggsave("JOLE/publication/replication/figure/figure4/figure4C_violence.eps", device = "eps", width = 6, height = 4)

#4C - report effect
figure4C_rep    <- fread("JOLE/publication/replication/data/figure4/figure4C_report.csv")
ybks            <- round(seq(-0.2,0.1,0.05), digits=2)
yscale          <- c(-0.2,0.1)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure4C_rep)
ggsave("JOLE/publication/replication/figure/figure4/figure4C_report.eps", device = "eps", width = 6, height = 4)




# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####               Figure 5: Heterogeneity           ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

ylabel          <- c("Employment Rate")

#figure5 - left
figure5_left    <- fread("JOLE/publication/replication/data/figure5/figure5_left.csv")
ybks            <- round(seq(-0.15,0.15,0.05), digits = 2)
yscale          <- c(-0.15,0.15)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('No','Yes')
stratify_title  <- c('Give Birth After Reporting')
subtitle        <- c('Sample: Young Female Once-Reporter (Age 25-35)')

graph2_color2(figure5_left)
ggsave("JOLE/publication/replication/figure/figure5/figure5_left.eps", device = "eps", width = 6, height = 4)
subtitle        <- c("")



#figure5 - right
figure5_right   <- fread("JOLE/publication/replication/data/figure5/figure5_right.csv")

figure5_right   <- figure5_right[!grepl("\\.2", variable)]
figure5_right   <- figure5_right[!grepl("\\.1", variable)]
figure5_right   <- figure5_right[!grepl("\\.3", variable)]
figure5_right[, variable := gsub("\\.4", ".0", variable)]
figure5_right[, variable := gsub("\\.5", ".1", variable)]

ybks            <- round(seq(-0.15,0.15,0.05), digits = 2)
yscale          <- c(-0.15,0.15)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Never Divorced (Married Year <10) ', 'Divorced After Reporting')
stratify_title  <- c("Divorce Decision")
subtitle        <- c("Sample: Youngs Without Giving Birth After Reporting")

graph2_color(figure5_right)
ggsave("JOLE/publication/replication/figure/figure5/figure5_right.eps", device = "eps", width = 6, height = 4)
subtitle        <- c("")






# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####      Figure 6: Depression Outpatient Visit      ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

ylabel          <- c("Depression Visit Dummy")

#6A - violence effect
figure6A_vio    <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
ybks            <- seq(-0.04,0.04,0.02)
yscale          <- c(-0.04,0.04)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figure6A_vio)
ggsave("JOLE/publication/replication/figure/figure6/figure6A_violence.eps", device = "eps", width = 6, height = 4)

#6A - report effect
figure6A_rep    <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
ybks            <- seq(-0.04,0.04,0.02)
yscale          <- c(-0.04,0.04)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figure6A_rep)
ggsave("JOLE/publication/replication/figure/figure6/figure6A_report.eps", device = "eps", width = 6, height = 4)

#6B - violence effect
figure6B_vio    <- fread("JOLE/publication/replication/data/figure6/figure6B_violence.csv")
ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure6B_vio)
ggsave("JOLE/publication/replication/figure/figure6/figure6B_violence.eps", device = "eps", width = 6, height = 4)

#6B - report effect
figure6B_rep    <- fread("JOLE/publication/replication/data/figure6/figure6B_report.csv")
ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figure6B_rep)
ggsave("JOLE/publication/replication/figure/figure6/figure6B_report.eps", device = "eps", width = 6, height = 4)

#6C - violence effect
figure6C_vio    <- fread("JOLE/publication/replication/data/figure6/figure6C_violence.csv")
ybks            <- round(seq(-0.06,0.06,0.03), digits=2)
yscale          <- c(-0.06,0.06)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure6C_vio)
ggsave("JOLE/publication/replication/figure/figure6/figure6C_violence.eps", device = "eps", width = 6, height = 4)

#6C - report effect
figure6C_rep    <- fread("JOLE/publication/replication/data/figure6/figure6C_report.csv")
ybks            <- round(seq(-0.06,0.06,0.03), digits=2)
yscale          <- c(-0.06,0.06)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Middle School Or Below','High School Finished', 'At Least College')
stratify_title  <- c("Education")

graph_geom(figure6C_rep)
ggsave("JOLE/publication/replication/figure/figure6/figure6C_report.eps", device = "eps", width = 6, height = 4)




# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####                Figure A.1:  Raw Data            ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

ylabel          <- c("Employment Rate")

#A.1A - violence
figureA1A_vio   <- fread("JOLE/publication/replication/data/figureA1/figureA1A_violence.csv")
ybks            <- round(seq(0.5,0.8,0.05), digits = 3)
yscale          <- c(0.5,0.8)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1A_vio)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1A_violence.eps", device = "eps", width = 6, height = 4)

#A.1A - report
figureA1A_rep   <- fread("JOLE/publication/replication/data/figureA1/figureA1A_report.csv")
ybks            <- round(seq(0.5,0.8,0.05), digits = 3)
yscale          <- c(0.5,0.8)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1A_rep)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1A_rerport.eps", device = "eps", width = 6, height = 4)



ylabel          <- c("Get Divorced Dummy")

#A.1B - violence
figureA1B_vio   <- fread("JOLE/publication/replication/data/figureA1/figureA1B_violence.csv")
ybks            <- round(seq(0,0.12,0.02), digits = 3)
yscale          <- c(0,0.12)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1B_vio)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1B_violence.eps", device = "eps", width = 6, height = 4)

#A.1B - report
figureA1B_rep   <- fread("JOLE/publication/replication/data/figureA1/figureA1B_report.csv")
ybks            <- round(seq(0,0.12,0.02), digits = 3)
yscale          <- c(0,0.12)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1B_rep)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1B_report.eps", device = "eps", width = 6, height = 4)



ylabel          <- c("Fertility Rate")

#A.1C - violence
figureA1C_vio   <- fread("JOLE/publication/replication/data/figureA1/figureA1C_violence.csv")
ybks            <- round(seq(0,0.1,0.02), digits = 3)
yscale          <- c(0.02,0.1)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1C_vio)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1C_violence.eps", device = "eps", width = 6, height = 4)

#A.1C - report
figureA1C_rep   <- fread("JOLE/publication/replication/data/figureA1/figureA1C_report.csv")
ybks            <- round(seq(0,0.1,0.02), digits = 3)
yscale          <- c(0.02,0.1)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1C_rep)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1C_report.eps", device = "eps", width = 6, height = 4)



ylabel          <- c("Depression Visit Dummy")

#A.1D - violence
figureA1D_vio   <- fread("JOLE/publication/replication/data/figureA1/figureA1D_violence.csv")
ybks            <- round(seq(0,0.15,0.03), digits = 3)
yscale          <- c(0,0.15)
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1D_vio)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1D_violence.eps", device = "eps", width = 6, height = 4)

#A.1D - report
figureA1D_rep   <- fread("JOLE/publication/replication/data/figureA1/figureA1D_report.csv")
ybks            <- round(seq(0,0.15,0.03), digits = 3)
yscale          <- c(0,0.15)
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched Control','Female Once-Reporter')
stratify_title  <- c("Sample")

graph_raw(figureA1D_rep)
ggsave("JOLE/publication/replication/figure/figureA1/figureA1D_report.eps", device = "eps", width = 6, height = 4)





# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####         Figure A.2: Violence Only Effect        ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

###Panel A
labor_1one      <- fread("JOLE/publication/replication/data/figureA2/labor_1one.csv")
labor_2two      <- fread("JOLE/publication/replication/data/figureA2/labor_2two.csv")
labor_3three    <- fread("JOLE/publication/replication/data/figureA2/labor_3three.csv")

labor_2two[, variable := gsub("\\.1", ".2", variable)]
labor_3three[, variable := gsub("\\.1", ".3", variable)]

labor_1one[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
labor_2two[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
labor_3three[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]

labor_1one      <- labor_1one[period<=0][, period := NULL]
labor_2two      <- labor_2two[period<=1][, period := NULL]
labor_3three    <- labor_3three[period<=2][, period := NULL]

figureA2A       <- rbind(labor_1one,labor_2two,labor_3three)
ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect (Without Any Report Effect)")
stratify_group  <- c('Report 1 Yr After IPV','Report 2 Yrs After IPV','Report 3 Yrs After IPV')
stratify_title  <- c("Group")

violence_only(figureA2A)
ggsave("JOLE/publication/replication/figure/figureA2/figureA2A.eps", device = "eps", width = 6, height = 4)

###Panel B
div_1one        <- fread("JOLE/publication/replication/data/figureA2/div_1one.csv")
div_2two        <- fread("JOLE/publication/replication/data/figureA2/div_2two.csv")
div_3three      <- fread("JOLE/publication/replication/data/figureA2/div_3three.csv")

div_2two[, variable := gsub("\\.1", ".2", variable)]
div_3three[, variable := gsub("\\.1", ".3", variable)]

div_1one[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
div_2two[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
div_3three[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]

div_1one        <- div_1one[period<=0][, period := NULL]
div_2two        <- div_2two[period<=1][, period := NULL]
div_3three      <- div_3three[period<=2][, period := NULL]

figureA2B       <- rbind(div_1one,div_2two,div_3three)
ybks            <- round(seq(-0.03,0.06,0.03), digits = 3)
yscale          <- c(-0.03,0.06)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect (Without Any Report Effect)")
stratify_group  <- c('Report 1 Yr After IPV','Report 2 Yrs After IPV','Report 3 Yrs After IPV')
stratify_title  <- c("Group")

violence_only(figureA2B)
ggsave("JOLE/publication/replication/figure/figureA2/figureA2B.eps", device = "eps", width = 6, height = 4)

###Panel C
fert_1one       <- fread("JOLE/publication/replication/data/figureA2/fert_1one.csv")
fert_2two       <- fread("JOLE/publication/replication/data/figureA2/fert_2two")
fert_3three     <- fread("JOLE/publication/replication/data/figureA2/fert_3three")

fert_2two[, variable := gsub("\\.1", ".2", variable)]
fert_3three[, variable := gsub("\\.1", ".3", variable)]

fert_1one[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
fert_2two[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
fert_3three[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]

fert_1one       <- fert_1one[period<=0][, period := NULL]
fert_2two       <- fert_2two[period<=1][, period := NULL]
fert_3three     <- fert_3three[period<=2][, period := NULL]

figureA2C       <- rbind(fert_1one,fert_2two,fert_3three)
ybks            <- round(seq(-0.03,0.06,0.03), digits = 3)
yscale          <- c(-0.03,0.06)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect (Without Any Report Effect)")
stratify_group  <- c('Report 1 Yr After IPV','Report 2 Yrs After IPV','Report 3 Yrs After IPV')
stratify_title  <- c("Group")

violence_only(figureA2C)
ggsave("JOLE/publication/replication/figure/figureA2/figureA2C.eps", device = "eps", width = 6, height = 4)

###Panel D
dep_1one        <- fread("JOLE/publication/replication/data/figureA2/dep_1one.csv")
dep_2two        <- fread("JOLE/publication/replication/data/figureA2/dep_2two.csv")
dep_3three      <- fread("JOLE/publication/replication/data/figureA2/dep_3three.csv")

dep_2two[, variable := gsub("\\.1", ".2", variable)]
dep_3three[, variable := gsub("\\.1", ".3", variable)]

dep_1one[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
dep_2two[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]
dep_3three[, period := sub(".*y(-?[0-9]+)\\..*", "\\1", variable)]

dep_1one        <- dep_1one[period<=0][, period := NULL]
dep_2two        <- dep_2two[period<=1][, period := NULL]
dep_3three      <- dep_3three[period<=2][, period := NULL]

figureA2D       <- rbind(dep_1one,dep_2two,dep_3three)


ybks            <- round(seq(-0.02,0.04,0.02), digits = 3)
yscale          <- c(-0.02,0.04)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect (Without Any Report Effect)")
stratify_group  <- c('Report 1 Yr After IPV','Report 2 Yrs After IPV','Report 3 Yrs After IPV')
stratify_title  <- c("Group")

violence_only(figureA2D)
ggsave("JOLE/publication/replication/figure/figureA2/figureA2D.eps", device = "eps", width = 6, height = 4)








# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####        Figure A.3: Different Victim Group       ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure A.3A - violence
pooled_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
re_pooled_labor <- fread("JOLE/publication/replication/data/figureA3/re_pooled_labor.csv")
m_pooled_labor  <- fread("JOLE/publication/replication/data/figureA3/m_pooled_labor.csv")

re_pooled_labor[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_pooled_labor[, new_group              := 2]
re_pooled_labor[, variable               := paste0(first,".",new_group)]
re_pooled_labor[, first := NULL][, new_group := NULL]

m_pooled_labor[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_pooled_labor[, new_group              := 3]
m_pooled_labor[, variable               := paste0(first,".",new_group)]
m_pooled_labor[, first := NULL][, new_group := NULL]

figureA3A_vio   <- rbind(m_pooled_labor,re_pooled_labor,pooled_labor)

ybks            <- round(seq(-0.1,0.06,0.02), digits = 3)
yscale          <- c(-0.1,0.06)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3A_vio)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3A_violence.eps", device = "eps", width = 6, height = 4)



#Figure A.3A - report
report_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
re_report_labor <- fread("JOLE/publication/replication/data/figureA3/re_report_labor.csv")
m_report_labor  <- fread("JOLE/publication/replication/data/figureA3/m_report_labor.csv")

re_report_labor[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_report_labor[, new_group              := 2]
re_report_labor[, variable               := paste0(first,".",new_group)]
re_report_labor[, first := NULL][, new_group := NULL]

m_report_labor[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_report_labor[, new_group              := 3]
m_report_labor[, variable               := paste0(first,".",new_group)]
m_report_labor[, first := NULL][, new_group := NULL]

figureA3A_rep   <- rbind(re_report_labor,m_report_labor,report_labor)

ybks            <- round(seq(-0.1,0.06,0.02), digits = 3)
yscale          <- c(-0.1,0.06)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3A_rep)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3A_report.eps", device = "eps", width = 6, height = 4)



#Figure A.3B - violence
pooled_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
re_pooled_div   <- fread("JOLE/publication/replication/data/figureA3/re_pooled_div.csv")
m_pooled_div    <- fread("JOLE/publication/replication/data/figureA3/m_pooled_div.csv")

re_pooled_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_pooled_div[, new_group              := 2]
re_pooled_div[, variable               := paste0(first,".",new_group)]
re_pooled_div[, first := NULL][, new_group := NULL]

m_pooled_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_pooled_div[, new_group              := 3]
m_pooled_div[, variable               := paste0(first,".",new_group)]
m_pooled_div[, first := NULL][, new_group := NULL]

figureA3B_vio   <- rbind(m_pooled_div,re_pooled_div,pooled_divorce)

ybks            <- seq(-0.02,0.1,0.02)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3B_vio)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3B_violence.eps", device = "eps", width = 6, height = 4)




#Figure A.3B - report
report_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
re_report_div   <- fread("JOLE/publication/replication/data/figureA3/re_report_div.csv")
m_report_div    <- fread("JOLE/publication/replication/data/figureA3/m_report_div.csv")

re_report_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_report_div[, new_group              := 2]
re_report_div[, variable               := paste0(first,".",new_group)]
re_report_div[, first := NULL][, new_group := NULL]

m_report_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_report_div[, new_group              := 3]
m_report_div[, variable               := paste0(first,".",new_group)]
m_report_div[, first := NULL][, new_group := NULL]

figureA3B_rep   <- rbind(m_report_div,re_report_div,report_divorce)

ybks            <- seq(-0.02,0.1,0.02)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3B_rep)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3B_report.eps", device = "eps", width = 6, height = 4)




#Figure A.3C - violence
pooled_fert     <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
re_pooled_birth <- fread("JOLE/publication/replication/data/figureA3/re_pooled_birth.csv")
m_pooled_birth  <- fread("JOLE/publication/replication/data/figureA3/m_pooled_birth.csv")

re_pooled_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_pooled_birth[, new_group              := 2]
re_pooled_birth[, variable               := paste0(first,".",new_group)]
re_pooled_birth[, first := NULL][, new_group := NULL]

m_pooled_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_pooled_birth[, new_group              := 3]
m_pooled_birth[, variable               := paste0(first,".",new_group)]
m_pooled_birth[, first := NULL][, new_group := NULL]

figureA3C_vio   <- rbind(m_pooled_birth,re_pooled_birth,pooled_fert)

ybks            <- seq(-0.09,0.09,0.03)
yscale          <- c(-0.09,0.09)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3C_vio)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3C_violence.eps", device = "eps", width = 6, height = 4)



#Figure A.3C - report
report_fert     <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
re_report_birth <- fread("JOLE/publication/replication/data/figureA3/re_report_birth.csv")
m_report_birth  <- fread("JOLE/publication/replication/data/figureA3/m_report_birth.csv")

re_report_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_report_birth[, new_group              := 2]
re_report_birth[, variable               := paste0(first,".",new_group)]
re_report_birth[, first := NULL][, new_group := NULL]

m_report_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_report_birth[, new_group              := 3]
m_report_birth[, variable               := paste0(first,".",new_group)]
m_report_birth[, first := NULL][, new_group := NULL]

figureA3C_rep   <- rbind(m_report_birth,re_report_birth,report_fert)

ybks            <- seq(-0.09,0.09,0.03)
yscale          <- c(-0.09,0.09)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3C_rep)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3C_report.eps", device = "eps", width = 6, height = 4)



#Figure A.3D - violence
pooled_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
re_pooled_mental<- fread("JOLE/publication/replication/data/figureA3/re_pooled_mental.csv")
m_pooled_mental <- fread("JOLE/publication/replication/data/figureA3/m_pooled_mental.csv")

re_pooled_mental[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_pooled_mental[, new_group              := 2]
re_pooled_mental[, variable               := paste0(first,".",new_group)]
re_pooled_mental[, first := NULL][, new_group := NULL]

m_pooled_mental[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_pooled_mental[, new_group              := 3]
m_pooled_mental[, variable               := paste0(first,".",new_group)]
m_pooled_mental[, first := NULL][, new_group := NULL]

figureA3D_vio   <- rbind(m_pooled_mental,re_pooled_mental,pooled_dep)

ybks            <- seq(-0.05,0.05,0.025)
yscale          <- c(-0.05,0.05)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3D_vio)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3D_violence.eps", device = "eps", width = 6, height = 4)



#Figure A.3D - report
report_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
re_report_mental<- fread("JOLE/publication/replication/data/figureA3/re_report_mental.csv")
m_report_mental <- fread("JOLE/publication/replication/data/figureA3/m_report_mental.csv")

re_report_mental[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
re_report_mental[, new_group              := 2]
re_report_mental[, variable               := paste0(first,".",new_group)]
re_report_mental[, first := NULL][, new_group := NULL]

m_report_mental[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
m_report_mental[, new_group              := 3]
m_report_mental[, variable               := paste0(first,".",new_group)]
m_report_mental[, first := NULL][, new_group := NULL]

figureA3D_rep   <- rbind(m_report_mental,re_report_mental,report_dep)

ybks            <- seq(-0.05,0.05,0.025)
yscale          <- c(-0.05,0.05)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter','Female Repeat-reporter','Male Once-reporter')
stratify_title  <- c("Group")

graph_geom(figureA3D_rep)
ggsave("JOLE/publication/replication/figure/figureA3/figureA3D_report.eps", device = "eps", width = 6, height = 4)





# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####            Figure A.4: Report Channel           ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure A.4A - violence
figureA4A_vio   <- fread("JOLE/publication/replication/data/figureA4/figureA4A_violence.csv")
figureA4A_vio[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4A_vio   <- figureA4A_vio[stratify_group %in% c(1:3)]

ybks            <- seq(-0.12,0.12,0.04)
yscale          <- c(-0.12,0.12)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Violence Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4A_vio)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4A_violence.eps", device = "eps", width = 6, height = 4)




#Figure A.4A - report
figureA4A_rep   <- fread("JOLE/publication/replication/data/figureA4/figureA4A_report.csv")
figureA4A_rep[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4A_rep   <- figureA4A_rep[stratify_group %in% c(1:3)]

ybks            <- seq(-0.12,0.12,0.04)
yscale          <- c(-0.12,0.12)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
output.name     <- c("report_s_source_labor")
output.path     <- c("Data/figure/")
main_title      <- c("Report Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4A_rep)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4A_report.eps", device = "eps", width = 6, height = 4)



#Figure A.4B - violence
figureA4B_vio <- fread("JOLE/publication/replication/data/figureA4/figureA4B_violence.csv")
figureA4B_vio[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4B_vio <- figureA4B_vio[stratify_group %in% c(1:3)]

ybks            <- seq(-0.05,0.125,0.025)
yscale          <- c(-0.05,0.125)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Violence Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4B_vio)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4B_violence.eps", device = "eps", width = 6, height = 4)



#Figure A.4B - report
figureA4B_rep <- fread("JOLE/publication/replication/data/figureA4/figureA4B_report.csv")
figureA4B_rep[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4B_rep <- figureA4B_rep[stratify_group %in% c(1:3)]

ybks            <- seq(-0.05,0.125,0.025)
yscale          <- c(-0.05,0.125)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4B_rep)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4B_report.eps", device = "eps", width = 6, height = 4)



#Figure A.4C - violence
figureA4C_vio   <- fread("JOLE/publication/replication/data/figureA4/figureA4C_violence.csv")
figureA4C_vio[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4C_vio   <- figureA4C_vio[stratify_group %in% c(1:3)]

ybks            <- round(seq(-0.08,0.12,0.04), digits=2)
yscale          <- c(-0.08,0.13)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Violence Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4C_vio)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4C_violence.eps", device = "eps", width = 6, height = 4)




#Figure A.4C - report
figureA4C_rep   <- fread("JOLE/publication/replication/data/figureA4/figureA4C_report.csv")
figureA4C_rep[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4C_rep   <- figureA4C_rep[stratify_group %in% c(1:3)]

ybks            <- round(seq(-0.08,0.12,0.04), digits=2)
yscale          <- c(-0.08,0.13)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4C_rep)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4C_report.eps", device = "eps", width = 6, height = 4)



#Figure A.4D - violence
figureA4D_vio   <- fread("JOLE/publication/replication/data/figureA4/figureA4D_violence.csv")
figureA4D_vio[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4D_vio   <- figureA4D_vio[stratify_group %in% c(1:3)]

ybks            <- seq(-0.1,0.1,0.05)
yscale          <- c(-0.1,0.1)
ylabel          <- c("Depression Outpatient Visit")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Report Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4D_vio)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4D_violence.eps", device = "eps", width = 6, height = 4)



#Figure A.4D - report
figureA4D_rep   <- fread("JOLE/publication/replication/data/figureA4/figureA4D_report.csv")
figureA4D_rep[, c("first","stratify_group") := tstrsplit(variable,".",fixed=T)]
figureA4D_rep   <- figureA4D_rep[stratify_group %in% c(1:3)]

ybks            <- seq(-0.1,0.1,0.05)
yscale          <- c(-0.1,0.1)
ylabel          <- c("Depression Outpatient Visit")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Police','Hospital','Helpline')
stratify_title  <- c("Report Source")

graph_geom(figureA4D_rep)
ggsave("JOLE/publication/replication/figure/figureA4/figureA4D_report.eps", device = "eps", width = 6, height = 4)







# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####         Figure A.5: Duration = 2 vs Full        ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure A.5A - violence
full_labor      <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
two_labor       <- fread("JOLE/publication/replication/data/figureA5/figureA5A_violence.csv")
full_labor[, variable := gsub("\\.1", ".0", variable)]

figureA5A_vio   <- rbind(full_labor,two_labor)

ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5A_vio)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5A_violence.eps", device = "eps", width = 6, height = 4)


#Figure A.5A - report
full_labor_r    <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
two_labor_r     <- fread("JOLE/publication/replication/data/figureA5/figureA5A_report.csv")
full_labor_r[, variable := gsub("\\.1", ".0", variable)]

figureA5A_rep   <- rbind(full_labor_r,two_labor_r)

ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5A_rep)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5A_report.eps", device = "eps", width = 6, height = 4)


#Figure A.5B - violence
full_div        <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
two_div         <- fread("JOLE/publication/replication/data/figureA5/figureA5B_violence.csv")
full_div[, variable := gsub("\\.1", ".0", variable)]

figureA5B_vio   <- rbind(full_div,two_div)

ybks            <- round(seq(-0.03,0.15,0.03), digits = 3)
yscale          <- c(-0.03,0.15)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5B_vio)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5B_violence.eps", device = "eps", width = 6, height = 4)


#Figure A.5B - report
full_div_r      <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
two_div_r       <- fread("JOLE/publication/replication/data/figureA5/figureA5B_report.csv")
full_div_r[, variable := gsub("\\.1", ".0", variable)]

figureA5B_rep   <- rbind(full_div_r,two_div_r)

ybks            <- round(seq(-0.03,0.15,0.03), digits = 3)
yscale          <- c(-0.03,0.15)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5B_rep)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5B_report.eps", device = "eps", width = 6, height = 4)


#Figure A.5C - violence
full_fert       <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
two_fert        <- fread("JOLE/publication/replication/data/figureA5/figureA5C_violence.csv")
full_fert[, variable := gsub("\\.1", ".0", variable)]

figureA5C_vio   <- rbind(full_fert,two_fert)

ybks            <- round(seq(-0.06,0.06,0.02), digits = 3)
yscale          <- c(-0.07,0.06)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5C_vio)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5C_violence.eps", device = "eps", width = 6, height = 4)


#Figure A.5C - report
full_fert_r     <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
two_fert_r      <- fread("JOLE/publication/replication/data/figureA5/figureA5C_report.csv")
full_fert_r[, variable := gsub("\\.1", ".0", variable)]

figureA5C_rep   <- rbind(full_fert_r,two_fert_r)

ybks            <- round(seq(-0.06,0.06,0.02), digits = 3)
yscale          <- c(-0.07,0.06)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5C_rep)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5C_report.eps", device = "eps", width = 6, height = 4)


#Figure A.5D - violence
full_dep        <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
two_dep         <- fread("JOLE/publication/replication/data/figureA5/figureA5D_violence.csv")
full_dep[, variable := gsub("\\.1", ".0", variable)]

figureA5D_vio   <- rbind(full_dep,two_dep)

ybks            <- round(seq(-0.06,0.09,0.03), digits = 3)
yscale          <- c(-0.07,0.09)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5D_vio)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5D_violence.eps", device = "eps", width = 6, height = 4)


#Figure A.5D - report
full_dep_r      <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
two_dep_r       <- fread("JOLE/publication/replication/data/figureA5/figureA5D_report.csv")
full_dep_r[, variable := gsub("\\.1", ".0", variable)]

figureA5D_rep <- rbind(full_dep_r,two_dep_r)

ybks            <- round(seq(-0.06,0.09,0.03), digits = 3)
yscale          <- c(-0.07,0.09)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('All Female Once-reporter','Duration = 2')
stratify_title  <- c("Sample")

graph2(figureA5D_rep)
ggsave("JOLE/publication/replication/figure/figureA5/figureA5D_report.eps", device = "eps", width = 6, height = 4)





# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####           Figure A.6: Instant Reporter          ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#employment rate
figureA6A       <- fread("JOLE/publication/replication/data/figureA6/figureA6A.csv")
ybks            <- seq(-0.03,0.06,0.03)
yscale          <- c(-0.03,0.06)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Employment Rate")

graph(figureA6A)
ggsave("JOLE/publication/replication/figure/figureA6/figureA6A.eps", device = "eps", width = 6, height = 4)

#divorce
figureA6B       <- fread("JOLE/publication/replication/data/figureA6/figureA6B.csv")
ybks            <- seq(-0.02,0.08,0.02)
yscale          <- c(-0.02,0.08)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Divorce Decision")

graph(figureA6B)
ggsave("JOLE/publication/replication/figure/figureA6/figureA6B.eps", device = "eps", width = 6, height = 4)


#fertility
figureA6C       <- fread("JOLE/publication/replication/data/figureA6/figureA6C.csv")
ybks            <- round(seq(-0.075,0.05,0.025), digits = 3)
yscale          <- c(-0.075,0.05)
ylabel          <- c("Fertility Decision")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Fertility Rate")

graph(figureA6C)
ggsave("JOLE/publication/replication/figure/figureA6/figureA6C.eps", device = "eps", width = 6, height = 4)

#depression outpatient visit
figureA6D       <- fread("JOLE/publication/replication/data/figureA6/figureA6D.csv")
ybks            <- round(seq(-0.075,0.05,0.025), digits = 3)
yscale          <- c(-0.075,0.05)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Depression Outpatient Visit")

graph(figureA6D)
ggsave("JOLE/publication/replication/figure/figureA6/figureA6D.eps", device = "eps", width = 6, height = 4)







# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####               Figure A.7 Matched DiD            ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure A.7A: violence
later_v_labor   <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
never_v_labor   <- fread("JOLE/publication/replication/data/figureA7/figureA7A_violence.csv")

never_v_labor[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
never_v_labor[, new_group              := 0]
never_v_labor[, variable               := paste0(first,".",new_group)]
never_v_labor[, first := NULL][, new_group := NULL]

figureA7A_vio   <- rbind(never_v_labor,later_v_labor)

ybks            <- seq(-0.03,0.03,0.01)
yscale          <- c(-0.03,0.03)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7A_vio)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7A_violence.eps", device = "eps", width = 6, height = 4)


#Figure A.7A: report
later_labor     <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
matched_labor   <- fread("JOLE/publication/replication/data/figureA7/figureA7A_report.csv")

matched_labor[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
matched_labor[, new_group              := 0]
matched_labor[, variable               := paste0(first,".",new_group)]
matched_labor[, first := NULL][, new_group := NULL]

figureA7A_rep   <- rbind(matched_labor,later_labor)

ybks            <- seq(-0.03,0.03,0.01)
yscale          <- c(-0.03,0.03)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7A_rep)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7A_report.eps", device = "eps", width = 6, height = 4)



#Figure A.7B: violence
later_v_divorce <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
never_v_divorce <- fread("JOLE/publication/replication/data/figureA7/figureA7B_violence.csv")

never_v_divorce[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
never_v_divorce[, new_group              := 0]
never_v_divorce[, variable               := paste0(first,".",new_group)]
never_v_divorce[, first := NULL][, new_group := NULL]

#violence effect
figureA7B_vio   <- rbind(never_v_divorce,later_v_divorce)

ybks            <- seq(0,0.1,0.02)
yscale          <- c(-0.01,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7B_vio)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7B_violence.eps", device = "eps", width = 6, height = 4)




#Figure A.7B: report
later_divorce   <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
matched_divorce <- fread("JOLE/publication/replication/data/figureA7/figureA7B_report.csv")

matched_divorce[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
matched_divorce[, new_group              := 0]
matched_divorce[, variable               := paste0(first,".",new_group)]
matched_divorce[, first := NULL][, new_group := NULL]

figureA7B_rep   <- rbind(matched_divorce,later_divorce)

ybks            <- seq(0,0.1,0.02)
yscale          <- c(-0.01,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7B_rep)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7B_report.eps", device = "eps", width = 6, height = 4)



#Figure A.7C: violence
later_v_birth   <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
never_v_birth <- fread("JOLE/publication/replication/data/figureA7/figureA7C_violence.csv")

never_v_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
never_v_birth[, new_group              := 0]
never_v_birth[, variable               := paste0(first,".",new_group)]
never_v_birth[, first := NULL][, new_group := NULL]

figureA7C_vio   <- rbind(never_v_birth,later_v_birth)

ybks            <- seq(-0.04,0.04,0.02)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7C_vio)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7C_violence.eps", device = "eps", width = 6, height = 4)


#Figure A.7C: report
later_birth     <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
matched_birth   <- fread("JOLE/publication/replication/data/figureA7/figureA7C_report.csv")

matched_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
matched_birth[, new_group              := 0]
matched_birth[, variable               := paste0(first,".",new_group)]
matched_birth[, first := NULL][, new_group := NULL]

figureA7C_rep   <- rbind(matched_birth,later_birth)

ybks            <- seq(-0.04,0.04,0.02)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7C_rep)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7C_report.eps", device = "eps", width = 6, height = 4)






#Figure A.7D: violence
later_v_mental  <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
never_v_mental  <- fread("JOLE/publication/replication/data/figureA7/figureA7D_violence.csv")

never_v_mental[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
never_v_mental[, new_group              := 0]
never_v_mental[, variable               := paste0(first,".",new_group)]
never_v_mental[, first := NULL][, new_group := NULL]

figureA7D_vio   <- rbind(never_v_mental,later_v_mental)

ybks            <- seq(-0.06,0.06,0.02)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Violence Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7D_vio)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7D_violence.eps", device = "eps", width = 6, height = 4)




#Figure A.7D: report
later_mental    <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
matched_mental  <- fread("JOLE/publication/replication/data/figureA7/figureA7D_report.csv")

matched_mental[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
matched_mental[, new_group              := 0]
matched_mental[, variable               := paste0(first,".",new_group)]
matched_mental[, first := NULL][, new_group := NULL]

figureA7D_rep   <- rbind(matched_mental,later_mental)

ybks            <- seq(-0.06,0.06,0.02)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Matched DiD','Staggered DiD')

graph2(figureA7D_rep)
ggsave("JOLE/publication/replication/figure/figureA7/figureA7D_report.eps", device = "eps", width = 6, height = 4)






# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####          Figure C.1: Other Labor Outcome        ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.1A - violence
figureC1A_vio   <- fread("JOLE/publication/replication/data/figureC1/figureC1A_violence.csv")
ybks            <- round(seq(-0.4,0.4,0.2), digits = 3)
yscale          <- c(-0.45,0.4)
ylabel          <- c("Full-Time Working Month Per Year")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC1A_vio)


#Figure C.1A - report
figureC1A_rep   <- fread("JOLE/publication/replication/data/figureC1/figureC1A_report.csv")
ybks            <- round(seq(-0.4,0.4,0.2), digits = 3)
yscale          <- c(-0.45,0.4)
ylabel          <- c("Full-Time Working Month Per Year")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC1A_rep)


#Figure C.1B - violence
figureC1B_vio   <- fread("JOLE/publication/replication/data/figureC1/figureC1B_violence.csv")
ybks            <- round(seq(-10000,10000,2500), digits = 3)
yscale          <- c(-10000,10000)
ylabel          <- c("Annual Income")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC1B_vio)


#Figure C.1B - report
figureC1B_rep  <- fread("JOLE/publication/replication/data/figureC1/figureC1B_report.csv")
ybks            <- round(seq(-10000,10000,2500), digits = 3)
yscale          <- c(-10000,10000)
ylabel          <- c("Annual Income")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC1B_rep)






# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####            Figure C.2  Overall Health           ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.2A - violence
figureC2A_vio   <- fread("JOLE/publication/replication/data/figureC2/figureC2A_violence.csv")

ybks            <- seq(-2000,1500,500)
yscale          <- c(-2000,1500)
ylabel          <- c("Depression Related Medical Cost")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC2A_vio)

#Figure C.2A - report
figureC2A_rep   <- fread("JOLE/publication/replication/data/figureC2/figureC2A_report.csv")

ybks            <- seq(-2000,1500,500)
yscale          <- c(-2000,1500)
ylabel          <- c("Depression Related Medical Cost")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC2A_rep)


#Figure C.2B - violence
figureC2B_vio   <- fread("JOLE/publication/replication/data/figureC2/figureC2B_violence.csv")

ybks            <- seq(-2000,1500,500)
yscale          <- c(-2000,1500)
ylabel          <- c("All Medical Cost Except Depression")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC2B_vio)


#Figure C.2B - report
figureC2B_rep   <- fread("JOLE/publication/replication/data/figureC2/figureC2B_report.csv")

ybks            <- seq(-2000,1500,500)
yscale          <- c(-2000,1500)
ylabel          <- c("All Medical Cost Except Depression")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC2B_rep)




# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####          Figure C.3: Male Employment Rate       ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.3A - violence
figureC3A_vio   <- fread("JOLE/publication/replication/data/figureC3/figureC3A_violence.csv")

ybks            <- round(seq(-0.15,0.15,0.05), digits = 2)
yscale          <- c(-0.15,0.15)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC3A_vio)

#Figure C.3A - report
figureC3A_rep   <- fread("JOLE/publication/replication/data/figureC3/figureC3A_report.csv")

ybks            <- round(seq(-0.15,0.15,0.05), digits = 2)
yscale          <- c(-0.15,0.15)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC3A_rep)


#Figure C.3B - violence
figureC3B_vio   <- fread("JOLE/publication/replication/data/figureC3/figureC3B_violence.csv")

ybks            <- seq(-0.2,0.2,0.1)
yscale          <- c(-0.2,0.2)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC3B_vio)


#Figure C.3B - report
figureC3B_rep   <- fread("JOLE/publication/replication/data/figureC3/figureC3B_report.csv")

ybks            <- seq(-0.2,0.2,0.1)
yscale          <- c(-0.2,0.2)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC3B_rep)



# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####         Figure C.4: Male Marital Decision       ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.4A - violence
figureC4A_vio   <- fread("JOLE/publication/replication/data/figureC4/figureC4A_violence.csv")

ybks            <- seq(-0.12,0.16,0.04)
yscale          <- c(-0.12,0.16)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC4A_vio)


#Figure C.4A - report
figureC4A_rep   <- fread("JOLE/publication/replication/data/figureC4/figureC4A_report.csv")

ybks            <- seq(-0.12,0.16,0.04)
yscale          <- c(-0.12,0.16)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC4A_rep)


#Figure C.4B - violence
figureC4B_vio   <- fread("JOLE/publication/replication/data/figureC4/figureC4B_violence.csv")

ybks            <- seq(-0.12,0.16,0.04)
yscale          <- c(-0.12,0.16)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC4B_vio)


#Figure C.4B - report
figureC4B_rep   <- fread("JOLE/publication/replication/data/figureC4/figureC4B_report.csv")

ybks            <- seq(-0.12,0.16,0.04)
yscale          <- c(-0.12,0.16)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC4B_rep)



# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####         Figure C.5: Male Fertility Rate         ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.5A - violence
figureC5A_vio   <- fread("JOLE/publication/replication/data/figureC5/figureC5A_violence.csv")

ybks            <- round(seq(-0.1,0.1,0.05), digits = 2)
yscale          <- c(-0.1,0.1)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC5A_vio)

#Figure C.5A - report
figureC5A_rep   <- fread("JOLE/publication/replication/data/figureC5/figureC5A_report.csv")

ybks            <- round(seq(-0.1,0.1,0.05), digits = 2)
yscale          <- c(-0.1,0.1)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC5A_rep)


#Figure C.5B - violence
figureC5B_vio   <- fread("JOLE/publication/replication/data/figureC5/figureC5B_violence.csv")

ybks            <- seq(-0.2,0.15,0.05)
yscale          <- c(-0.2,0.15)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC5B_vio)

#Figure C.5B - report
figureC5B_rep   <- fread("JOLE/publication/replication/data/figureC5/figureC5B_report.csv")

ybks            <- seq(-0.2,0.15,0.05)
yscale          <- c(-0.2,0.15)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC5B_rep)


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####   Figure C.6: Male Depression Outpatient Visit  ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.6A - violence
figureC6A_vio   <- fread("JOLE/publication/replication/data/figureC6/figureC6A_violence.csv")

ybks            <- seq(-0.06,0.06,0.02)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Outpatient-Visit")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")

graph(figureC6A_vio)

#Figure C.6A - report
figureC6A_rep   <- fread("JOLE/publication/replication/data/figureC6/figureC6A_report.csv")

ybks            <- seq(-0.06,0.06,0.02)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Outpatient-Visit")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")

graph(figureC6A_rep)


#Figure C.6B - violence
figureC6B_vio   <- fread("JOLE/publication/replication/data/figureC6/figureC6B_violence.csv")

ybks            <- round(seq(-0.15,0.15,0.05), digits = 2)
yscale          <- c(-0.15,0.15)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC6B_vio)


#Figure C.6B - report
figureC6B_rep   <- fread("JOLE/publication/replication/data/figureC6/figureC6B_report.csv")

ybks            <- round(seq(-0.15,0.15,0.05), digits = 2)
yscale          <- c(-0.15,0.15)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('25-35','36-45','46-55')
stratify_title  <- c("Age Group")

graph_geom(figureC6B_rep)





# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####          Figure C.7: Different Covariates       ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.7A - violence
pooled_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
v_con_serv_lab  <- fread("JOLE/publication/replication/data/figureC7/violence/severity/year_full_dummy41057TRUE.csv")
v_con_perp_lab  <- fread("JOLE/publication/replication/data/figureC7/violence/perp/year_full_dummy41057TRUE.csv")

v_con_perp_lab[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_perp_lab[, new_group              := 2]
v_con_perp_lab[, variable               := paste0(first,".",new_group)]
v_con_perp_lab[, first := NULL][, new_group := NULL]

v_con_serv_lab[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_serv_lab[, new_group              := 3]
v_con_serv_lab[, variable               := paste0(first,".",new_group)]
v_con_serv_lab[, first := NULL][, new_group := NULL]

figureC7A_vio   <- rbind(pooled_labor,v_con_perp_lab,v_con_serv_lab)

ybks            <- seq(-0.03,0.03,0.01)
yscale          <- c(-0.03,0.03)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")

graph_three_dot(figureC7A_vio)


#Figure C.7A - report
report_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
r_con_serv_lab  <- fread("JOLE/publication/replication/data/figureC7/report/severity/year_full_dummy90604FALSE.csv")
r_con_perp_lab  <- fread("JOLE/publication/replication/data/figureC7/report/perp/year_full_dummy90604FALSE.csv")

r_con_perp_lab[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_perp_lab[, new_group              := 2]
r_con_perp_lab[, variable               := paste0(first,".",new_group)]
r_con_perp_lab[, first := NULL][, new_group := NULL]

r_con_serv_lab[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_serv_lab[, new_group              := 3]
r_con_serv_lab[, variable               := paste0(first,".",new_group)]
r_con_serv_lab[, first := NULL][, new_group := NULL]

figureC7A_rep   <- rbind(report_labor,r_con_perp_lab,r_con_serv_lab)

ybks            <- seq(-0.03,0.03,0.01)
yscale          <- c(-0.03,0.03)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")

graph_three_dot(figureC7A_rep)


#Figure C.7B - violence
pooled_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
v_con_serv_div  <- fread("JOLE/publication/replication/data/figureC7/violence/severity/get_divorced41057TRUE.csv")
v_con_perp_div  <- fread("JOLE/publication/replication/data/figureC7/violence/perp/get_divorced41057TRUE.csv")

v_con_perp_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_perp_div[, new_group              := 2]
v_con_perp_div[, variable               := paste0(first,".",new_group)]
v_con_perp_div[, first := NULL][, new_group := NULL]

v_con_serv_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_serv_div[, new_group              := 3]
v_con_serv_div[, variable               := paste0(first,".",new_group)]
v_con_serv_div[, first := NULL][, new_group := NULL]

figureC7B_vio   <- rbind(pooled_divorce,v_con_perp_div,v_con_serv_div)

ybks            <- seq(-0.02,0.1,0.02)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")

graph_three_dot(figureC7B_vio)



#Figure C.7B - report
report_divorce    <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
r_con_serv_div  <- fread("JOLE/publication/replication/data/figureC7/report/severity/get_divorced90604FALSE.csv")
r_con_perp_div  <- fread("JOLE/publication/replication/data/figureC7/report/perp/get_divorced90604FALSE.csv")

r_con_perp_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_perp_div[, new_group              := 2]
r_con_perp_div[, variable               := paste0(first,".",new_group)]
r_con_perp_div[, first := NULL][, new_group := NULL]

r_con_serv_div[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_serv_div[, new_group              := 3]
r_con_serv_div[, variable               := paste0(first,".",new_group)]
r_con_serv_div[, first := NULL][, new_group := NULL]

figureC7B_rep   <- rbind(report_divorce,r_con_perp_div,r_con_serv_div)

ybks            <- seq(-0.02,0.1,0.02)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")

graph_three_dot(figureC7B_rep)


#Figure C.7C - violence
pooled_birth    <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
v_con_serv_birth<- fread("JOLE/publication/replication/data/figureC7/violence/severity/year_give_birth41057TRUE.csv")
v_con_perp_birth<- fread("JOLE/publication/replication/data/figureC7/violence/perp/year_give_birth41057TRUE.csv")

v_con_perp_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_perp_birth[, new_group              := 2]
v_con_perp_birth[, variable               := paste0(first,".",new_group)]
v_con_perp_birth[, first := NULL][, new_group := NULL]

v_con_serv_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_serv_birth[, new_group              := 3]
v_con_serv_birth[, variable               := paste0(first,".",new_group)]
v_con_serv_birth[, first := NULL][, new_group := NULL]

figureC7C_vio   <- rbind(pooled_birth,v_con_perp_birth,v_con_serv_birth)

ybks            <- seq(-0.04,0.04,0.01)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")

graph_three_dot(figureC7C_vio)


#Figure C.7C - report
report_birth    <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
r_con_serv_birth<- fread("JOLE/publication/replication/data/figureC7/report/severity/year_give_birth90604FALSE.csv")
r_con_perp_birth<- fread("JOLE/publication/replication/data/figureC7/report/perp/year_give_birth90604FALSE.csv")

r_con_perp_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_perp_birth[, new_group              := 2]
r_con_perp_birth[, variable               := paste0(first,".",new_group)]
r_con_perp_birth[, first := NULL][, new_group := NULL]

r_con_serv_birth[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_serv_birth[, new_group              := 3]
r_con_serv_birth[, variable               := paste0(first,".",new_group)]
r_con_serv_birth[, first := NULL][, new_group := NULL]

figureC7C_rep   <- rbind(report_birth,r_con_perp_birth,r_con_serv_birth)

ybks            <- seq(-0.04,0.04,0.01)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")

graph_three_dot(figureC7C_rep)


#Figure C.7D - violence
pooled_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
v_con_serv_dep  <- fread("JOLE/publication/replication/data/figureC7/violence/severity/depression_dummy41057TRUE.csv")
v_con_perp_dep  <- fread("JOLE/publication/replication/data/figureC7/violence/perp/depression_dummy41057TRUE.csv")

v_con_perp_dep[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_perp_dep[, new_group              := 2]
v_con_perp_dep[, variable               := paste0(first,".",new_group)]
v_con_perp_dep[, first := NULL][, new_group := NULL]

v_con_serv_dep[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
v_con_serv_dep[, new_group              := 3]
v_con_serv_dep[, variable               := paste0(first,".",new_group)]
v_con_serv_dep[, first := NULL][, new_group := NULL]

figureC7D_vio   <- rbind(pooled_dep,v_con_perp_dep,v_con_serv_dep)

ybks            <- seq(-0.04,0.04,0.01)
yscale          <- c(-0.045,0.04)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")

graph_three_dot(figureC7D_vio)


#Figure C.7D - report
report_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
r_con_serv_dep  <- fread("JOLE/publication/replication/data/figureC7/report/severity/depression_dummy90604FALSE.csv")
r_con_perp_dep  <- fread("JOLE/publication/replication/data/figureC7/report/perp/depression_dummy90604FALSE.csv")

r_con_perp_dep[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_perp_dep[, new_group              := 2]
r_con_perp_dep[, variable               := paste0(first,".",new_group)]
r_con_perp_dep[, first := NULL][, new_group := NULL]

r_con_serv_dep[, c("first","new_group") := tstrsplit(variable,".",fixed=T)]
r_con_serv_dep[, new_group              := 3]
r_con_serv_dep[, variable               := paste0(first,".",new_group)]
r_con_serv_dep[, first := NULL][, new_group := NULL]

figureC7D_rep   <- rbind(report_dep,r_con_perp_dep,r_con_serv_dep)

ybks            <- seq(-0.04,0.04,0.01)
yscale          <- c(-0.045,0.04)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With Perpetrator Outcomes','With Severity Index')
stratify_title  <- c("Covariate")


graph_three_dot(figureC7D_rep)







# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####        Figure C.8: Report Behavior Control      ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.8A - violence
baseline_labor  <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
duration_labor  <- fread("JOLE/publication/replication/data/figureC8/violence/duration/year_full_dummy41057TRUE.csv")
source_labor    <- fread("JOLE/publication/replication/data/figureC8/violence/source/year_full_dummy41057TRUE.csv")

duration_labor[, variable := gsub("\\.1", ".2", variable)]
source_labor[, variable := gsub("\\.1", ".3", variable)]

figureC8A_vio   <- rbind(baseline_labor,duration_labor,source_labor)

ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8A_vio)


#Figure C.8A - report
baseline_labor_r<- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
duration_labor_r<- fread("JOLE/publication/replication/data/figureC8/report/duration/year_full_dummy90604FALSE.csv")
source_labor_r  <- fread("JOLE/publication/replication/data/figureC8/report/source/year_full_dummy90604FALSE.csv")

duration_labor_r[, variable := gsub("\\.1", ".2", variable)]
source_labor_r[, variable := gsub("\\.1", ".3", variable)]

figureC8A_rep <- rbind(baseline_labor_r,duration_labor_r,source_labor_r)

ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8A_rep)



#Figure C.8B - violence
baseline_div    <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
duration_div    <- fread("JOLE/publication/replication/data/figureC8/violence/duration/get_divorced41057TRUE.csv")
source_div      <- fread("JOLE/publication/replication/data/figureC8/violence/source/get_divorced41057TRUE.csv")

duration_div[, variable := gsub("\\.1", ".2", variable)]
source_div[, variable := gsub("\\.1", ".3", variable)]

figureC8B_vio   <- rbind(baseline_div,duration_div,source_div)

ybks            <- round(seq(-0.02,0.10,0.02), digits = 3)
yscale          <- c(-0.02,0.10)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8B_vio)



#Figure C.8B - report
baseline_div_r  <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
duration_div_r  <- fread("JOLE/publication/replication/data/figureC8/report/duration/get_divorced90604FALSE.csv")
source_div_r    <- fread("JOLE/publication/replication/data/figureC8/report/source/get_divorced90604FALSE.csv")

duration_div_r[, variable := gsub("\\.1", ".2", variable)]
source_div_r[, variable := gsub("\\.1", ".3", variable)]

figureC8B_rep   <- rbind(baseline_div_r,duration_div_r,source_div_r)

ybks            <- round(seq(-0.02,0.10,0.02), digits = 3)
yscale          <- c(-0.02,0.10)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8B_rep)


#Figure C.8C - violence
baseline_fert    <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
duration_fert    <- fread("JOLE/publication/replication/data/figureC8/violence/duration/year_give_birth41057TRUE.csv")
source_fert      <- fread("JOLE/publication/replication/data/figureC8/violence/source/year_give_birth41057TRUE.csv")

duration_fert[, variable := gsub("\\.1", ".2", variable)]
source_fert[, variable := gsub("\\.1", ".3", variable)]

figureC8C_vio    <- rbind(baseline_fert,duration_fert,source_fert)

ybks            <- round(seq(-0.05,0.05,0.025), digits = 3)
yscale          <- c(-0.05,0.05)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8C_vio)


#Figure C.8C - report
baseline_fert_r <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
duration_fert_r <- fread("JOLE/publication/replication/data/figureC8/report/duration/year_give_birth90604FALSE.csv")
source_fert_r   <- fread("JOLE/publication/replication/data/figureC8/report/source/year_give_birth90604FALSE.csv")

duration_fert_r[, variable := gsub("\\.1", ".2", variable)]
source_fert_r[, variable := gsub("\\.1", ".3", variable)]

figureC8C_rep   <- rbind(baseline_fert_r,duration_fert_r,source_fert_r)

ybks            <- round(seq(-0.05,0.05,0.025), digits = 3)
yscale          <- c(-0.05,0.05)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8C_rep)




#Figure C.8D - violence
baseline_dep    <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
duration_dep    <- fread("JOLE/publication/replication/data/figureC8/violence/duration/depression_dummy41057TRUE.csv")
source_dep      <- fread("JOLE/publication/replication/data/figureC8/violence/source/depression_dummy41057TRUE.csv")

duration_dep[, variable := gsub("\\.1", ".2", variable)]
source_dep[, variable := gsub("\\.1", ".3", variable)]

figureC8D_vio   <- rbind(baseline_dep,duration_dep,source_dep)

ybks            <- round(seq(-0.05,0.05,0.025), digits = 3)
yscale          <- c(-0.05,0.05)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8D_vio)


#Figure C.8D - report
baseline_dep_r <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
duration_dep_r <- fread("JOLE/publication/replication/data/figureC8/report/duration/depression_dummy90604FALSE.csv")
source_dep_r   <- fread("JOLE/publication/replication/data/figureC8/report/source/depression_dummy90604FALSE.csv")

duration_dep_r[, variable := gsub("\\.1", ".2", variable)]
source_dep_r[, variable := gsub("\\.1", ".3", variable)]

figureC8D_rep  <- rbind(baseline_dep_r,duration_dep_r,source_dep_r)

ybks            <- round(seq(-0.05,0.05,0.025), digits = 3)
yscale          <- c(-0.05,0.05)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Baseline','With IPV Duration','With Report Source')
stratify_title  <- c("Covariate")

graph_three_dot(figureC8D_rep)








# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####            Figure C.9: Alternative DiD          ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.9A - violence
pooled_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
labor_comp_v    <- fread("JOLE/publication/replication/data/figureC9/figureC9A_violence.csv")
pooled_labor    <- prep_compare(pooled_labor)
labor_comp_v    <- prep_compare2(labor_comp_v)
figureC9A_vio   <- rbind(pooled_labor,labor_comp_v, fill = TRUE)

ybks            <- round(seq(-0.08,0.04,0.04), digits = 3)
yscale          <- c(-0.08,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figureC9A_vio)



#Figure C.9A - report
report_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
labor_comp_r    <- fread("JOLE/publication/replication/data/figureC9/figureC9A_report.csv")
report_labor    <- prep_compare(report_labor)
labor_comp_r    <- prep_compare2(labor_comp_r)
figureC9A_rep   <- rbind(report_labor,labor_comp_r, fill = TRUE)

ybks            <- round(seq(-0.08,0.04,0.04), digits = 3)
yscale          <- c(-0.08,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figureC9A_rep)


#Figure C.9B - violence
pooled_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
div_comp_v      <- fread("JOLE/publication/replication/data/figureC9/figureC9B_violence.csv")
pooled_divorce  <- prep_compare(pooled_divorce)
div_comp_v      <- prep_compare2(div_comp_v)
figureC9B_vio   <- rbind(pooled_divorce,div_comp_v, fill = TRUE)

ybks            <- round(seq(-0.02,0.1,0.02), digits = 3)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figureC9B_vio)


#Figure C.9B - report
report_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
div_comp_r      <- fread("JOLE/publication/replication/data/figureC9/figureC9B_report.csv")
report_divorce  <- prep_compare(report_divorce)
div_comp_r      <- prep_compare2(div_comp_r)
figure9B_rep    <- rbind(report_divorce,div_comp_r, fill = TRUE)

ybks            <- round(seq(-0.02,0.1,0.02), digits = 3)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figure9B_rep)




#Figure C.9C - violence
pooled_birth    <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
birth_comp_v    <- fread("JOLE/publication/replication/data/figureC9/figureC9C_violence.csv")
pooled_birth    <- prep_compare(pooled_birth)
birth_comp_v    <- prep_compare2(birth_comp_v)
figureC9C_vio   <- rbind(pooled_birth,birth_comp_v, fill = TRUE)

ybks            <- round(seq(-0.08,0.08,0.04), digits = 3)
yscale          <- c(-0.08,0.08)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figureC9C_vio)


#Figure C.9C - report
report_birth    <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
birth_comp_r    <- fread("JOLE/publication/replication/data/figureC9/figureC9C_report.csv")
report_birth    <- prep_compare(report_birth)
birth_comp_r    <- prep_compare2(birth_comp_r)
figure9C_rep    <- rbind(report_birth,birth_comp_r, fill = TRUE)

ybks            <- round(seq(-0.08,0.08,0.04), digits = 3)
yscale          <- c(-0.08,0.08)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figure9C_rep)






#Figure C.9D - violence
pooled_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
dep_comp_v      <- fread("JOLE/publication/replication/data/figureC9/figureC9D_violence.csv")
pooled_dep      <- prep_compare(pooled_dep)
dep_comp_v      <- prep_compare2(dep_comp_v)
figureC9D_vio   <- rbind(pooled_dep,dep_comp_v, fill = TRUE)

ybks            <- round(seq(-0.06,0.06,0.03), digits = 3)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figureC9D_vio)


#Figure C.9D - report
report_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
dep_comp_r      <- fread("JOLE/publication/replication/data/figureC9/figureC9D_report.csv")
report_dep      <- prep_compare(report_dep)
dep_comp_r      <- prep_compare2(dep_comp_r)
figure9D_rep    <- rbind(report_dep,dep_comp_r, fill = TRUE)

ybks            <- round(seq(-0.06,0.06,0.03), digits = 3)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('CS (Baseline)','TWFE','SA')
stratify_title  <- c("Alternative DiD")

graph_compare(figure9D_rep)




# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####              Figure C.10: Double DiD            ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.10A
double_labor    <- fread("JOLE/publication/replication/data/figureC10/figureC10A_double.csv")
labor_r_b1      <- fread("JOLE/publication/replication/data/figureC10/figureC10A_staggered.csv")
labor_r_b1      <- labor_r_b1[model==1]

ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Staggered DiD','Double DiD')
stratify_title  <- c("Regression")

double_labor    <- prep_double(double_labor)
labor_r_b1      <- prep_compare_b1(labor_r_b1)
figureC10A      <- rbind(double_labor,labor_r_b1)

graph_csdid(figureC10A)


#Figure C.10B
double_div      <- fread("JOLE/publication/replication/data/figureC10/figureC10B_double.csv")
div_r_b1        <- fread("JOLE/publication/replication/data/figureC10/figureC10B_staggered.csv")
div_r_b1        <- div_r_b1[model==1]

ybks            <- seq(-0.03,0.12,0.03)
yscale          <- c(-0.03,0.12)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Staggered DiD','Double DiD')
stratify_title  <- c("Regression")

double_div      <- prep_double(double_div)
div_r_b1        <- prep_compare_b1(div_r_b1)
figureC10B      <- rbind(double_div,div_r_b1)

graph_csdid(figureC10B)



#Figure C.10C
double_fert     <- fread("JOLE/publication/replication/data/figureC10/figureC10C_double.csv")
fert_r_b1       <- fread("JOLE/publication/replication/data/figureC10/figureC10C_staggered.csv")
fert_r_b1       <- fert_r_b1[model==1]

ybks            <- seq(-0.05,0.15,0.05)
yscale          <- c(-0.05,0.15)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Staggered DiD','Double DiD')
stratify_title  <- c("Regression")

double_fert     <- prep_double(double_fert)
fert_r_b1       <- prep_compare_b1(fert_r_b1)
figureC10C      <- rbind(double_fert,fert_r_b1)

graph_csdid(figureC10C)



#Figure C.10D
double_dep      <- fread("JOLE/publication/replication/data/figureC10/figureC10D_double.csv")
dep_r_b1        <- fread("JOLE/publication/replication/data/figureC10/figureC10D_staggered.csv")
dep_r_b1        <- dep_r_b1[model==1]

ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Staggered DiD','Double DiD')
stratify_title  <- c("Regression")

double_dep      <- prep_double(double_dep)
dep_r_b1        <- prep_compare_b1(dep_r_b1)
figureC10D       <- rbind(double_dep,dep_r_b1)

graph_csdid(figureC10D)







# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####        Figure C.11: Month/Quarter Analysis      ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.11A - month
figureC11A_month<- fread("JOLE/publication/replication/data/figureC11/figureC11A_month.csv")

ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Month to IPV Report")
main_title      <- c("Report Effect")
m_xbks          <- seq(-24,24,3)
m_right_bound   <- -24
m_left_bound    <- 24

graph_month(figureC11A_month)


#Figure C.11A - quarter
figureC11A_qua  <- fread("JOLE/publication/replication/data/figureC11/figureC11A_quarter.csv")

ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Quarter to IPV Report")
main_title      <- c("Report Effect")
m_xbks          <- seq(-12,12,4)
m_right_bound   <- -12
m_left_bound    <- 12

graph_month(figureC11A_qua)


#Figure C.11B - month
figureC11B_month<- fread("JOLE/publication/replication/data/figureC11/figureC11B_month.csv")

ybks            <- round(seq(-0.05,0.025,0.025), digits = 3)
yscale          <- c(-0.05,0.025)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Month to IPV Report")
main_title      <- c("Report Effect")
m_xbks          <- seq(-24,24,3)
m_right_bound   <- -24
m_left_bound    <- 24

graph_month(figureC11B_month)



#Figure C.11B - quarter
figureC11B_qua  <- fread("JOLE/publication/replication/data/figureC11/figureC11B_quarter.csv")

ybks            <- round(seq(-0.05,0.025,0.025), digits = 3)
yscale          <- c(-0.05,0.025)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Quarter to IPV Report")
main_title      <- c("Report Effect")
m_xbks          <- seq(-12,12,4)
m_right_bound   <- -12
m_left_bound    <- 12

graph_month(figureC11B_qua)





# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####   Figure C.12: Heterogeneity By Survey Status   ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.12A
report_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
viosamp_r_labor <- fread("JOLE/publication/replication/data/figureC12/figureC12A.csv")

report_labor    <- report_labor[, variable := gsub("\\.1$", ".0", variable)]
figureC12A      <- rbind(report_labor,viosamp_r_labor)

ybks            <- round(seq(-0.04,0.04,0.02), digits = 3)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
xlabel          <- c("Year to IPV Report")
stratify_group  <- c('All Female Once-reporter','Only Those Surveyed (Duration = 1-9)')
stratify_title  <- c("Sample")

graph2(figureC12A)



#Figure C.12B
report_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
viosamp_r_div   <- fread("JOLE/publication/replication/data/figureC12/figureC12B.csv")

report_divorce  <- report_divorce[, variable := gsub("\\.1$", ".0", variable)]
figureC12B      <- rbind(report_divorce,viosamp_r_div)

ybks            <- seq(-0.02,0.12,0.02)
yscale          <- c(-0.02,0.12)
ylabel          <- c("Get Divorced Dummy")
main_title      <- c("Report Effect")
xlabel          <- c("Year to IPV Report")
stratify_group  <- c('All Female Once-reporter','Only Those Surveyed (Duration = 1-9)')
stratify_title  <- c("Sample")

graph2(figureC12B)



#Figure C.12C
report_fert     <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
viosamp_r_fert  <- fread("JOLE/publication/replication/data/figureC12/figureC12C.csv")

report_fert     <- report_fert[, variable := gsub("\\.1$", ".0", variable)]
figureC12C      <- rbind(report_fert,viosamp_r_fert)

ybks            <- seq(-0.06,0.02,0.02)
yscale          <- c(-0.06,0.02)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('All Female Once-reporter','Only Those Surveyed (Duration = 1-9)')
stratify_title  <- c("Sample")

graph2(figureC12C)


#Figure C.12D
report_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
viosamp_r_dep   <- fread("JOLE/publication/replication/data/figureC12/figureC12D.csv")

report_dep      <- report_dep[, variable := gsub("\\.1$", ".0", variable)]
figureC12D      <- rbind(report_dep,viosamp_r_dep)

ybks            <- seq(-0.06,0.06,0.02)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('All Female Once-reporter','Only Those Surveyed (Duration = 1-9)')
stratify_title  <- c("Sample")

graph2(figureC12D)







# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
####   Figure C.13: Robustness on 2014-2018 Sample   ####
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

#Figure C.13A - violence
pooled_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_violence.csv")
robust_v_labor  <- fread("JOLE/publication/replication/data/figureC13/figureC13A_violence.csv")

pooled_labor[, variable := gsub("\\.1", ".0", variable)]
figureC13A_vio  <- rbind(pooled_labor,robust_v_labor)

ybks            <- seq(-0.04,0.04,0.02)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13A_vio)



#Figure C.13A - report
report_labor    <- fread("JOLE/publication/replication/data/figure2/figure2A_report.csv")
robust_r_labor  <- fread("JOLE/publication/replication/data/figureC13/figureC13A_report.csv")

report_labor[, variable := gsub("\\.1", ".0", variable)]
figureC13A_rep  <- rbind(report_labor,robust_r_labor)

ybks            <- seq(-0.04,0.04,0.02)
yscale          <- c(-0.04,0.04)
ylabel          <- c("Employment Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13A_rep)




#Figure C.13B - violence
pooled_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_violence.csv")
robust_v_divorce<- fread("JOLE/publication/replication/data/figureC13/figureC13B_violence.csv")

pooled_divorce[, variable := gsub("\\.1", ".0", variable)]
figureC13B_vio  <- rbind(pooled_divorce,robust_v_divorce)

ybks            <- seq(-0.02,0.1,0.02)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13B_vio)




#Figure C.13B - report
report_divorce  <- fread("JOLE/publication/replication/data/figure3/figure3A_report.csv")
robust_r_divorce<- fread("JOLE/publication/replication/data/figureC13/figureC13B_report.csv")

report_divorce[, variable := gsub("\\.1", ".0", variable)]
figureC13B_rep  <- rbind(report_divorce,robust_r_divorce)

ybks            <- seq(-0.02,0.1,0.02)
yscale          <- c(-0.02,0.1)
ylabel          <- c("Get Divorced Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13B_rep)




#Figure C.13C - violence
pooled_fert     <- fread("JOLE/publication/replication/data/figure4/figure4A_violence.csv")
robust_v_fert   <- fread("JOLE/publication/replication/data/figureC13/figureC13C_violence.csv")

pooled_fert[, variable := gsub("\\.1", ".0", variable)]
figureC13C_vio  <- rbind(pooled_fert,robust_v_fert)

ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13C_vio)



#Figure C.13C - report
report_fert     <- fread("JOLE/publication/replication/data/figure4/figure4A_report.csv")
robust_r_fert   <- fread("JOLE/publication/replication/data/figureC13/figureC13C_report.csv")

report_fert[, variable := gsub("\\.1", ".0", variable)]
figureC13C_rep  <- rbind(report_fert,robust_r_fert)

ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Fertility Rate")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13C_rep)





#Figure C.13D - violence
pooled_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_violence.csv")
robust_v_dep    <- fread("JOLE/publication/replication/data/figureC13/figureC13D_violence.csv")

pooled_dep[, variable := gsub("\\.1", ".0", variable)]
figureC13D_vio  <- rbind(pooled_dep,robust_v_dep)

ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Onset")
main_title      <- c("Violence Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13D_vio)




#Figure C.13D - report
report_dep      <- fread("JOLE/publication/replication/data/figure6/figure6A_report.csv")
robust_r_dep    <- fread("JOLE/publication/replication/data/figureC13/figureC13D_report.csv")

report_dep[, variable := gsub("\\.1", ".0", variable)]
figureC13D_rep  <- rbind(report_dep,robust_r_dep)

ybks            <- seq(-0.06,0.06,0.03)
yscale          <- c(-0.06,0.06)
ylabel          <- c("Depression Visit Dummy")
xlabel          <- c("Year to IPV Report")
main_title      <- c("Report Effect")
stratify_group  <- c('Female Once-reporter in 2012-2018','Only 2014-2018')
stratify_title  <- c("Sample")

graph2(figureC13D_rep)

























